package com.lancoo.znbkxx.teacher.ui.fragment

import android.content.Intent
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.adapter.ExpandTrainAdapter
import com.lancoo.znbkxx.teacher.base.BaseVMFragment
import com.lancoo.znbkxx.teacher.databinding.FmtExpandTrainBinding
import com.lancoo.znbkxx.teacher.ui.activity.AddExpandQuesActivity
import com.lancoo.znbkxx.teacher.viewmodel.HardSolutionViewModel

import kotlinx.android.synthetic.main.fmt_expand_train.*

/**
 *@author Admin
 *@date 2021/2/26
 *
 */
class ExpandTrainFragment : BaseVMFragment<HardSolutionViewModel, FmtExpandTrainBinding>(),
        BaseQuickAdapter.OnItemClickListener {
    private val typeName by lazy { arguments?.getString("typeName") }
    lateinit var adapter: ExpandTrainAdapter
    override fun setLayoutID(): Int {
        return R.layout.fmt_expand_train
    }

    override fun providerContext(): Any? {
        return activity
    }

    override fun providerVMClass(): Class<HardSolutionViewModel>? {
        return HardSolutionViewModel::class.java
    }

    override fun initView() {
        adapter = ExpandTrainAdapter(typeName!!,viewModel.answerSkillComment.value!!.RecQuesID)
        adapter.onItemClickListener = this
        rv.layoutManager = LinearLayoutManager(requireContext())
        rv.adapter = adapter
        tv_expand.setOnClickListener {
            activity?.startActivityForResult(
                    Intent(requireContext(), AddExpandQuesActivity::class.java).apply {
                        putExtra("typeNo", viewModel.answerSkillComment.value!!.TypeNo)
                        putExtra("genreID", viewModel.answerSkillComment.value!!.GenreID)
                        putExtra("ids",viewModel.answerSkillComment.value!!.RecQuesID)
                    }, 300)
        }
    }


    override fun onItemClick(adapter: BaseQuickAdapter<*, *>?, view: View?, position: Int) {

    }
}